<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <h1>欢迎XX登录</h1>

    <!-- <p style="">
        <a href="">登录</a>
        <a href="">注册</a>
    </p> -->

    <script>

        const cookies = document.cookie;
        let arr = cookies.split('; ');
        arr = arr.map(v => {
            const arr2 = v.split('=');
            const obj = {};
            obj.name = arr2[0];
            obj.content = arr2[1];
            return obj;
        })
        console.log(arr);


        // 找who
        const res = arr.filter(v => v.name === 'who')[0];
        if (res) {
            const oH = document.querySelector('h1');
            oH.innerHTML = `欢迎${res.content}登录`;
        } else {
            alert('还没登录');
        }

    </script>

</body>

</html>